package com.wtwd.campus.hxy.service.impl;


import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.wtwd.campus.hxy.dao.HxyFenceMapper;
import com.wtwd.campus.hxy.model.entity.HxyFence;
import com.wtwd.campus.hxy.service.HxyFenceService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author zdl
 * @since 2021-07-27
 */
@Service
public class HxyFenceServiceImpl implements HxyFenceService {

    @Resource
    private HxyFenceMapper hxyFenceMapper;

    @Override
    public int save(HxyFence fence) {
        return hxyFenceMapper.insert(fence);
    }

    @Override
    public int delete(String key) {
        return hxyFenceMapper.deleteById(key);
    }

    @Override
    public int updateByKey(HxyFence fence) {
        return hxyFenceMapper.updateById(fence);
    }

    @Override
    public List<HxyFence> getFenceByImei(String imei) {
        return new LambdaQueryChainWrapper<>(hxyFenceMapper)
                .eq(HxyFence::getImei, imei)
                .list();
    }

}
